﻿using System;
using System.IO;
using Mono.Cecil.PE;

namespace Mono.Cecil.Cil
{
	// Token: 0x0200012E RID: 302
	public sealed class PortablePdbWriterProvider : ISymbolWriterProvider
	{
		// Token: 0x06000B7B RID: 2939 RVA: 0x00033F98 File Offset: 0x00032198
		public ISymbolWriter GetSymbolWriter(ModuleDefinition module, string fileName)
		{
			Mixin.CheckModule(module);
			Mixin.CheckFileName(fileName);
			FileStream value = File.Open(Mixin.GetPdbFileName(fileName), FileMode.OpenOrCreate, FileAccess.ReadWrite);
			return this.GetSymbolWriter(module, Disposable.Owned<Stream>(value), Disposable.NotOwned<Stream>(null));
		}

		// Token: 0x06000B7C RID: 2940 RVA: 0x00033FDC File Offset: 0x000321DC
		public ISymbolWriter GetSymbolWriter(ModuleDefinition module, Stream symbolStream)
		{
			Mixin.CheckModule(module);
			Mixin.CheckStream(symbolStream);
			return this.GetSymbolWriter(module, Disposable.Owned<Stream>(new MemoryStream()), Disposable.NotOwned<Stream>(symbolStream));
		}

		// Token: 0x06000B7D RID: 2941 RVA: 0x00034014 File Offset: 0x00032214
		private ISymbolWriter GetSymbolWriter(ModuleDefinition module, Disposable<Stream> stream, Disposable<Stream> final_stream)
		{
			MetadataBuilder metadataBuilder = new MetadataBuilder(module, this);
			ImageWriter writer = ImageWriter.CreateDebugWriter(module, metadataBuilder, stream);
			return new PortablePdbWriter(metadataBuilder, module, writer, final_stream);
		}
	}
}
